﻿using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Server;

namespace MQTT.Server.App
{
    public class MqttServerHost : IHostedService
    {

        private readonly IServerManager _server;
        public MqttServerHost(IServerManager server)
        {
            _server = server;
        }

        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await _server.Init().StartAsync();
        }

        public async Task StopAsync(CancellationToken cancellationToken)
        {
            await _server.StopAsync();
        }
    }
}
